package com.org.flow;

import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.context.ConfigurableApplicationContext;
import org.springframework.core.env.Environment;
import org.mybatis.spring.annotation.MapperScan;
import org.springframework.transaction.annotation.EnableTransactionManagement;

import java.net.InetAddress;
import java.net.UnknownHostException;

@SpringBootApplication(scanBasePackages = {"com.org.flow.element", "com.org.flow"})
@EnableTransactionManagement
@MapperScan("com.org.flow.system.mapper")
public class LiteFlowApplication {
	public static void main(String[] args) throws UnknownHostException {
		ConfigurableApplicationContext application = SpringApplication.run(LiteFlowApplication.class, args);
		Environment env = application.getEnvironment();
		String ip = InetAddress.getLocalHost().getHostAddress();
		String port = env.getProperty("server.port");
		String property = env.getProperty("server.servlet.context-path");
		String path = property == null ? "" : property;
		String position = "1".equals(System.getProperty("local")) ? " Local " : " Remote ";
		System.out.println(
				"\n\t" +
						"----------------------------------------------------------\n\t" +
						"Application Boot is running! Access URLs:\n\t" +
						"Local: \t\t http://localhost:" + port + path + "/ \n\t" +
						"External: \t http://" + ip + ":" + port + path + "/ \n\t" +
						"Running position: \t " + position + "/\n\t" +
						"------------------------------------------------------------");
	}

}
